package com.bitdf.txing.group.feign.impl.chat;

import com.bitdf.txing.chat.feign.ChatUserFeignService;
import com.bitdf.txing.common.enume.TxCodeEnume;
import com.bitdf.txing.common.utils.R;
import com.bitdf.txing.common.vo.UserInfoVo;
import com.bitdf.txing.users.entity.UserEntity;
import com.bitdf.txing.users.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lizhiwei
 * @date 2023/9/6 20:38:39
 * 注释：
 */
@Service
@ConditionalOnProperty(value = "tx.deploy.mode", havingValue = "standalone")
public class ChatUserFeignServiceImpl implements ChatUserFeignService {
    @Autowired
    UserService userService;
    @Override
    public R getByUserList(List<Long> list) {
        List<UserInfoVo> list2 = userService.getByUserList(list);
        return R.ok().put("data", list2);
    }

    @Override
    public R getUserById(Long id) {
        UserEntity user = userService.getById(id);
        if (user == null) {
            return R.error(TxCodeEnume.COMMON_TARGET_NOT_EXIST_EXCEPTION);
        }
        UserInfoVo userInfoVo = new UserInfoVo();
        BeanUtils.copyProperties(user, userInfoVo);
        return R.ok().put("data", userInfoVo);
    }
}
